<?php

	if (!isset($strScreenName))
		$strScreenName = 'DisplayOwnDetails';
	$strQueryName = 'qryAddCustomer';
	$strFormName = 'frmEnterCustomer';
//$strScreenName = "EnterCustomer";
	$strButtonTitle = "register";
	//$strScreenName = 'DisplayOwnDetails';
	//Screen name will be changed on succesfull execution of SQL
	if(!isset($SHOP_TYPE))
		$SHOP_TYPE = null;
	if($SHOP_TYPE == "Trade")
	{
		$strHeader = "New Trade Customer Registration";
		$strAddressHeader = "Company Name";
		$strAddressLine2Header = "*Address :&nbsp;";
	}else{
		$strHeader = "New Customer Registration";
		$strAddressHeader = "Address";
		$strAddressLine2Header = "&nbsp;";
	}
	
	$cboCountry = 202;

	if(isset($boReprocessing))
	{
		
	}else{
		if((isset($_REQUEST['intCustomerID']) && ctype_digit($_REQUEST['intCustomerID'])) Or ($_SESSION['sesCustID']))
		{
			include (MODULE . "/action/qrySelectCustomer");
			$strHeader = "Update My Details";
			$strButtonTitle = "update";
			//$strScreenName = "EnterCustomer";
			$cboID = stripslashes($myrow["ID"]);
			$cboTitle = stripslashes($myrow["Title"]);
			$txtFirstName = stripslashes($myrow["FirstName"]);
			$txtSurname = stripslashes($myrow["Surname"]);
			$txtAddress1 = stripslashes($myrow["Address1"]);
			$txtAddress2 = stripslashes($myrow["Address2"]);
			$txtCity = stripslashes($myrow["City"]);
			$txtRegion = stripslashes($myrow["Region"]);
			$txtPostalCode = stripslashes($myrow["PostalCode"]);
			$txtVATNumber = stripslashes($myrow["VATNumber"]);
			$cboValidFor = stripslashes($myrow["ValidFor"]);
			$cboCurrencyProfile = stripslashes($myrow["CurrencyProfile"]);
			$cboCountry = stripslashes($myrow["Country"]);
			$txtPhone = stripslashes($myrow["Phone"]);
			$txtFax = stripslashes($myrow["Fax"]);
			$txtActual_FAX = stripslashes($myrow["Actual_FAX"]);
			$txtEmail = stripslashes($myrow["Email"]);		
			$txtEmail2 = stripslashes($myrow["Email"]);
			$txtOtherInfo = stripslashes($myrow["OtherInfo"]);
			$txtPassword = stripslashes($myrow["Password"]);
			$cboReferrer = stripslashes($myrow["Referrer"]);
		}
	}

echo StartForm($strScreenName, "post", $strQueryName,array('strScreenName'=>$strScreenName,'intCustomerID'=>$intCustomerID,'boReprocessing'=>'True'),"","",$strFormName,"","return frmEnterCustomer_onsubmit()");

	if($strStyleSheet == TRUE){
		echo "<div id='VendereScreen'><table class='Normal' align='left' >";
	}	
echo "
<tr>
     <td>
         <table  width='100%' cellpadding='0' cellspacing='0' border='0' class='Normal' align='center'>
	 
			 <tr>
		         <td align='left' colspan='2' height='5'><img src='./imajes/space.gif' height='5' border='0' alt='' /></td>
		     </tr>
		     
			 <tr>
		         <td align='left' colspan='2'>
		             <h3>$strHeader</h3>
		         </td>
		     </tr>


		     <tr>
		         <td align='right' colspan='2'>
		             <input type='image' src='./images".SITE_SUFFIX."/".$strButtonTitle.".gif' alt='Save'  />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Title :&nbsp;</b>
		         </td>
		         <td align='left'>";
		             CreateDropDown("cboTitle", "SELECT * FROM tblTitle ORDER BY 2", "", $cboTitle);
					 
					 	if( (isset($_SESSION['sesUserType'])) && ($_SESSION['sesUserType'] == "staff"))
					 	{
							echo "<a href='".ScreenURL("EnterTitle")."' target='_blank'>+</a>";
						}
				 echo "
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>First Name :&nbsp;</b>
				 </td>
				 <td align='left'>
		             <input type=\"text\" name=\"txtFirstName\" value = \"$txtFirstName\" size= \"25\" maxlength=\"40\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Surname :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtSurname\" value = \"$txtSurname\" size= \"25\" maxlength=\"30\" />
		         </td>
		     </tr>
		
			 
			
			<tr>
			 	<td align='left'>
					<br /><b>";
				 
				 if($SHOP_TYPE == "Trade")
				 	echo "Company Name &amp; Address";
				 else
				 	echo "Card Holder Address";
				 
				 echo "
				 </b></td>
			 	<td>
					&nbsp;
				</td>
			</tr>  
			
			<tr>
			 	<td colspan='2'>
					<hr />
				</td>
			</tr>

		     <tr>
		         <td align='right'>
		             *<b>$strAddressHeader :&nbsp;</b>
				 </td>
		         <td align='left'>
		             <input type=\"text\" name=\"txtAddress1\" value = \"$txtAddress1\" size= \"30\" maxlength=\"60\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align='right'>
				 	<b>$strAddressLine2Header</b>
				 </td>
		         <td align='left'>
		             <input type=\"text\" name=\"txtAddress2\" value = \"$txtAddress2\" size= \"30\" maxlength=\"60\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Town / City :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtCity\" value = \"$txtCity\" size= \"30\" maxlength=\"30\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>County /&nbsp;State :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtRegion\" value = \"$txtRegion\" size= \"25\" maxlength=\"25\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Postal Code :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtPostalCode\" value = \"$txtPostalCode\" size= \"10\" maxlength=\"10\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Country :&nbsp;</b>
		         </td>
		         <td align='left'>";
		             CreateDropDown("cboCountry", "SELECT * FROM tblCountry ORDER BY 2", "", $cboCountry);
						
						if( (isset($_SESSION['sesUserType'])) && ($_SESSION['sesUserType'] == "staff"))
							echo "<a href='".ScreenURL("EnterCountry")."' target='_blank'>+</a>";
		?>
		         </td>
		     </tr>
		     <?php
		     if($SHOP_TYPE == "Trade")
		     {
		    	echo "
		     <tr>
		         <td align=\"right\">
		             <b>VAT Number :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtVATNumber\" value = \"$txtVATNumber\" size= \"12\" maxlength=\"12\" />
		         </td>
		     </tr>";
			}
			
			if( (isset($_SESSION['sesUserType'])) && ($_SESSION['sesUserType'] == "staff"))
		    {
		    	echo "
			 <tr>
			 	<td colspan='2'>
					<br/><hr/>
				</td>
			 </tr>
		     <tr>
		         <td align=\"right\">
		             <b>Valid for (days) :&nbsp;</b>
		         </td>
		         <td align='left'>";
		           CreateDropDown("cboValidFor", "SELECT * FROM tblUserValidity ORDER BY 2", "", $cboValidFor);
		         echo 
		         "</td>
		     </tr>

			<tr>
		         <td align=\"right\">
		             <b>Profile :&nbsp;</b>
		         </td>
		         <td align='left'>";
		           CreateDropDown("cboCurrencyProfile", "SELECT * FROM tblCurrencyProfile ORDER BY 2", "", $cboCurrencyProfile);
		         echo
		         "</td>
		     </tr>";
			}
		    ?>
			
			<tr>
			 	<td colspan='2'>
					<br/><hr/>
				</td>
			</tr>
		<?php
			echo "	
		     <tr>
		         <td align=\"right\">
		             *<b>Phone :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtPhone\" value = \"$txtPhone\" size= \"24\" maxlength=\"24\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             &nbsp;<b>Mobile / Daytime No.&nbsp;:&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtFax\" value = \"$txtFax\" size= \"24\" maxlength=\"24\" />
		         </td>
		     </tr>";
			if($SHOP_TYPE == "Trade"){
			echo "
			<tr>
		         <td align=\"right\">
		             &nbsp;<b>Fax No.&nbsp;:&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtActual_FAX\" value='$txtActual_FAX' size=\"24\" maxlength=\"24\" />
		         </td>
		     </tr>";	
			}
			
			
			echo "
		     <tr>
		         <td align='right'>
		             *<b>Email :&nbsp;</b>
				 </td>
		         <td align='left'>
		             <input type=\"text\" name=\"txtEmail\" value = \"$txtEmail\" size= \"30\" maxlength=\"100\" />
		         </td>
		     </tr>	
			 
			 <tr>
		         <td align='right'>
		             *<b>Confirm Email :&nbsp;</b>
				 </td>
		         <td align='left'>
		             <input type=\"text\" name=\"txtEmail2\" value = \"$txtEmail2\" size= \"30\" maxlength=\"100\" />
		         </td>
		     </tr>
		
			 <tr>
			 	<td colspan='2'>
					<br /><hr />
				</td>
			</tr>";
			if(($SHOP_TYPE == "Trade") && ($_SESSION['sesUserType'] != "staff"))
			{
				//omit password
			}
			else
			{
				echo "
		     <tr>
		         <td align=\"right\">
		             *<b>Password :&nbsp;</b>
				</td>
				<td>
		             <input type=\"password\" name=\"txtPassword\" size= \"20\" maxlength=\"40\" />
		         </td>
		     </tr>
		
		     <tr>
		         <td align=\"right\">
		             *<b>Re-enter Password :&nbsp;</b>
				</td>
				<td>
		             <input type=\"password\" name=\"txtPassword2\" size= \"20\" maxlength=\"40\" />
		         </td>
		     </tr>
				";
			}
		echo "
		     <tr>
		         <td align=\"right\">
		             *<b>How did you find us :&nbsp;</b>
		         </td>
		         <td align='left'>";
		             CreateDropDown("cboReferrer", "SELECT * FROM tblReferrer ORDER BY 2", "", $cboReferrer);
		
						if( (isset($_SESSION['sesUserType'])) && ($_SESSION['sesUserType'] == "staff"))
		             		echo "<a href='".ScreenURL("EnterReferrer")."' target='_blank'>+</a>";
		echo "
		         </td>
		     </tr>";
		
		if($SHOP_TYPE == "Trade")
		     {
		    	echo "
		     <tr>
		         <td align=\"right\">
		             <b>What year was the business established and your top 3 brands currently stocked :&nbsp;</b>
		         </td>
		         <td align='left'>
		           <input type=\"text\" name=\"txtOtherInfo\" value = \"$txtOtherInfo\" size= \"30\" maxlength=\"200\" />
		         </td>
		     </tr>";
			}
		echo "
		     <tr>
		         <td align='right' colspan='2'>
		             <input type='image' src='./images".SITE_SUFFIX."/".$strButtonTitle.".gif' alt='Save'  />
		         </td>
		     </tr>
			 
			 <tr>
		         <td align='right' colspan='2'>
		             * Required information to process order.
		         </td>
		     </tr>
         </table>
     
     </td>
 </tr>
";		
 if($strStyleSheet == TRUE){
		echo "</table></div>";
	}
     //$strListAll = "true";
       //include (MODULE . "/screen/ListCustomer");
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
function frmEnterCustomer_onsubmit() 
{


     if(document.frmEnterCustomer.txtFirstName.value == "") {
         alert("Please enter first name");
         document.frmEnterCustomer.txtFirstName.focus();
         document.frmEnterCustomer.txtFirstName.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtSurname.value == "") {
         alert("Please enter surname");
         document.frmEnterCustomer.txtSurname.focus();
         document.frmEnterCustomer.txtSurname.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtAddress1.value == "") {
         alert("Please enter address");
         document.frmEnterCustomer.txtAddress1.focus();
         document.frmEnterCustomer.txtAddress1.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtCity.value == "") {
         alert("Please enter town");
         document.frmEnterCustomer.txtCity.focus();
         document.frmEnterCustomer.txtCity.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtRegion.value == "") {
         alert("Please enter county");
         document.frmEnterCustomer.txtRegion.focus();
         document.frmEnterCustomer.txtRegion.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtPostalCode.value == "") {
         alert("Please enter post code");
         document.frmEnterCustomer.txtPostalCode.focus();
         document.frmEnterCustomer.txtPostalCode.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtPhone.value == "") {
         alert("Please enter phone number");
         document.frmEnterCustomer.txtPhone.focus();
         document.frmEnterCustomer.txtPhone.select();
         return(false);
     }else{
	 	if(document.frmEnterCustomer.txtPhone.value.substring(0,2) == "07") {
			alert("You have entered a mobile number, please enter a land line number.");
	        document.frmEnterCustomer.txtPhone.focus();
	        document.frmEnterCustomer.txtPhone.select();
	        return(false);
		}
	 }

     if(document.frmEnterCustomer.txtEmail.value == "") {
         alert("Please enter email address");
         document.frmEnterCustomer.txtEmail.focus();
         document.frmEnterCustomer.txtEmail.select();
         return(false);
     }else{
	 	 if(document.frmEnterCustomer.txtEmail.value == document.frmEnterCustomer.txtEmail2.value) {
         	
     	}else{
			alert("Email addresses don't match please retype them.");
         	document.frmEnterCustomer.txtEmail.focus();
         	document.frmEnterCustomer.txtEmail.select();
         	return(false);
		}
	 
	 
	 }

     if(document.frmEnterCustomer.txtPassword.value == "") {
         alert("Please enter password");
         document.frmEnterCustomer.txtPassword.focus();
         document.frmEnterCustomer.txtPassword.select();
         return(false);
     }

     if(document.frmEnterCustomer.txtPassword2.value == "") {
         alert("Please validate password");
         document.frmEnterCustomer.txtPassword2.focus();
         document.frmEnterCustomer.txtPassword2.select();
         return(false);
     }
}
// -->
</script>
